// 文章请求模块

import request from '../utils/request'

// 请求频道新闻推荐 v1.1
export const getArticles = data => {
  return request({
    method: 'GET',
    url: '/app/v1_1/articles',
    params: data
  })
}

// 请求频道新闻推荐列表 v1.1
export const getArticleById = articleId => {
  return request({
    method: 'GET',
    url: '/app/v1_0/articles/' + articleId
  })
}

// 收藏文章
export const addCollect = targetId => {
  return request({
    method: 'POST',
    url: '/app/v1_0/article/collections',
    data: {
      target: targetId
    }
  })
}

// 取消收藏
export const deleteCollect = targetId => {
  return request({
    method: 'DELETE',
    url: '/app/v1_0/article/collections/' + targetId
  })
}

// 点赞文章
export const addLike = targetId => {
  return request({
    method: 'POST',
    url: '/app/v1_0/article/likings',
    data: {
      target: targetId
    }
  })
}

// 取消点赞
export const deleteLike = targetId => {
  return request({
    method: 'DELETE',
    url: '/app/v1_0/article/likings/' + targetId
  })
}
